(function($){
	
	var osszeg = 0;
	
	function str2Num(str, options){
		//string to number
		options = options ? options : {};
		$.extend({
						dec_point		: '.',	//decimals' separator
						thousands_sep	: ',',	//thousands separator
					}, options);
		var num = str.split(options.thousands_sep).join('').split(options.dec_point).join('.');
		return parseFloat(num);
	}

	$(function(){
		$('td.t, td.k').click(function(e){
			if (e.ctrlKey) {		//a t vagy a k cellába kattintottunk úgy hogy a ctrl nyomva van
				var cell = $(this);
				var ertek = str2Num(cell.text(), {dec_point: ',', thousands_sep : '.'});
				osszeg += cell.hasClass('k') ? -1 * ertek : ertek;
				var t = 'information';
			}
			else{
				osszeg = 0;
				var t = 'alert'
			}
			noty({
					text: number_format(osszeg, 2, ',', '.'),
					layout: 'topRight',
					type: t,
					timeout: 50000,
					closeWith: ['click'],
					killer : true
				});
		});
	});
})(jQuery);